﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace Sublimation
{
    public class SlotFlame : SlotWeapon
    {
        protected const int NB_PER_WAVE = 20;
        public SlotFlame(WorldProperties worldProperties, SlotKind kind, Tower ownerTower)
            : base(worldProperties, kind, ownerTower,false)
        {
            rangeDisplayColor = Color.Red;
            RangedFlightSpeed = 500;
        }

        protected override void LoadContent()
        {
            base.LoadContent();
            Sprite = Game.Content.Load<Texture2D>("Sprites/flame_thrower_1");
        }

        protected override void RangedAttack(GameObject target, GameTime gameTime)
        {
            float slotRotation = orientation + ownerTower.Rotation;

            //get the minimum angle
            float min_angle = ((slotRotation - angle));


            //get the maximum angle
            float max_angle = ((slotRotation + angle)) ;


            Vector2 bulletVelocity;

            for (int i = 0; i < NB_PER_WAVE; i++)
            {
                float temp = i*(max_angle - min_angle) / NB_PER_WAVE;
                bulletVelocity = new Vector2((float)Math.Cos(temp + min_angle), (float)Math.Sin(temp + min_angle)); ;
                Vector2 bulletPosition = ownerTower.Position + Vector2.Normalize(bulletVelocity * RangedFlightSpeed) * (ownerTower.CollisionRadius + 10);
                new FireBall(worldProperties, true, bulletPosition, bulletVelocity, RangedFlightSpeed, new Vector2(10, 10), rangeAffected - Vector2.Distance(ownerTower.Position, bulletPosition), damageAffected);

            }
        }
    }
}

